package com.hongxun.design.fragments;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;

import java.util.List;

import com.hongxun.design.MyApp;
import com.hongxun.design.R;
import com.hongxun.design.adapters.BitTypeTabGridAdapter;
import com.hongxun.design.bean.BitTypeTabItemBean;
import com.hongxun.design.mytools.MString;
import com.hongxun.design.utils.DataUtil;

/**
 * Created by zerdoor_pc on 2016/5/6.
 */
public class BitTypeTabFragment extends Fragment {
    int type;
    GridView tab_grid;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View contactsLayout = inflater.inflate(R.layout.fragment_bittypetab,
                container, false);
        getBundle();
        findView(contactsLayout);
        inIt();
        return contactsLayout;
    }

    private void getBundle() {
        type = getArguments().getInt(MString.TYPE);
    }

    private void findView(View v) {
          tab_grid = (GridView) v.findViewById(R.id.tab_grid);

    }

    private void inIt() {
        List<BitTypeTabItemBean> BitData= getData();
        MyApp.BitData.clear();
        MyApp.BitData.addAll(BitData);
        BitTypeTabGridAdapter adapter=new BitTypeTabGridAdapter(BitData,getActivity());
        tab_grid.setAdapter(adapter);
    }

    private List<BitTypeTabItemBean> getData() {
       return  DataUtil.getBitTypeData(type);
    }


}
